package newcrunch.typography;

import java.util.Arrays;
import javax.swing.table.DefaultTableModel;

/**
 * @author WL
 */
public class TypoMainTableModel extends DefaultTableModel
{
    protected static final Object[][] DATA = new Object [][] {
                {"Spaces", null, null, null, null},
                {"Spaces after keywords except default, super, this, break, return, continue", null, "-", null, "-"},
                {"Spaces after super, default, this", null, "-", null, "-"},
                {"Spaces before and after binary operators except dot", null, "-", null, "-"},
                {"Spaces before and after dot", null, "-", null, null},
                {"Spaces before and after colon in assert, ternary and for loops", null, "-", null, "-"},
                {"Spaces before colon in switch cases and statement labels", null, "-", null, "-"},
                {"Spaces before a comma", null, "-", null, "-"},
                {"Spaces after a comma", null, "-", null, "-"},
                {"Spaces before semicolons", null, "-", null, ""},
                {"Spaces after semicolons in a for statement", null, "-", null, "-"},
                {"Spaces between method name and opening parenthesis", null, "-", null, "-"},
                {"Spaces between unary operator and operand", null, "-", null, "-"},
                {"Spaces between cast and expression being casted", null, "-", null, null},
                {"Spaces after opening parenthesis", null, "-", null, null},
                {"Spaces before closing parenthesis", null, "-", null, null},
                {"Spaces after opening square bracket", null, "-", null, null},
                {"Spaces before closing square bracket", null, "-", null, null},
                {"Spaces after opening angular bracket", null, "-", null, null},
                {"Spaces before closing angular bracket", null, "-", null, null},
                {null, null, null, null, null},
                {"Blank lines", null, null, null, null},
                {"Between package and import declaration section and classes", null, "-", null, null},
                {"Between classes", null, "-", null, null},
                {"Between methods", null, "-", null, null},
                {"Before block or single-line comments", null, "-", null, null},
                {"Between last field declaration and first method declaration", null, "-", null, null},
                {"Percentage of blank lines", null, "-", null, null},
                {"Percentage of lines containing comments", null, "-", null, null},
                {null, null, null, null, null},
                {"Identifier Naming", null, null, null, null},
                {"Number of single character identifiers outside for loops", null, "-", null, null},
                {"Variable naming", null, "-", null, null},
                {"Constant naming", null, "-", null, null},
                {"Method naming", null, "-", null, null},
                {"Class / Interface naming", null, "-", null, null},
                {null, null, null, null, null},
                {"General", null, null, null, null},
                {"Maximum number of statements per line", null, "-", null, null},
                {"Number of constructors", null, "-", null, null},
                {"Average length of method", null, "-", null, null},
                {"Average length of class", null, "-", null, null},
                {"Longest length of single line of code", null, "-", null, null},
                {"Bracing Style", null, "-", null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            };
    
    protected static final String[] HEADERS =  new String [] {
                            "Aspect", "Result", "Standard Deviation", "Standard", "Comments"
                        };
    
    
    Class[] types = new Class [] {
        java.lang.Object.class, java.lang.Object.class, String.class, 
        java.lang.String.class, java.lang.String.class
    };
    boolean[] canEdit = new boolean [] {
        false, false, false, false, true
    };

    public Class getColumnClass(int columnIndex) {
        return types [columnIndex];
    }

    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return Arrays.binarySearch(TypoMainTable.subheadingRows, rowIndex) < 0 && 
                DATA[rowIndex][0] != null && canEdit [columnIndex];
    }

    @Override
    public int getRowCount() {
        return DATA.length;
    }

    @Override
    public int getColumnCount() {
        return DATA[0].length;
    }

    @Override
    public String getColumnName(int columnIndex) {
        return HEADERS[columnIndex];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        return DATA[rowIndex][columnIndex];
    }

    @Override
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        DATA[rowIndex][columnIndex] = aValue;
    }
}
